package com.system.employee.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.system.FinancialDepartment.entity.RewardAndPunishiment;
import com.system.common.util.Sex;
import com.system.post.entity.Post;
import com.system.transfer.entity.Transfer;
import com.system.user.entity.User;

@Entity
@Table(name="t_employee")
public class Employee {
		private Long empId;	//员工id(唯一)
		private String empName;	//员工真实姓名
		private Sex sex;	//性别
		@DateTimeFormat(pattern="yyyy/MM/dd")  
		private Date birthday;	//生日
		@DateTimeFormat(pattern="yyyy/MM/dd")  
		private Date joinTime;	//进公司时间
		private String bornPlace;//出生地
		private String address;//住址
		private String email;	//邮箱
		private String phone;	//电话号码
		private String education;//学历
		private String political;//政治面貌
		private String ethnic;//民族
		private String idcard;//身份证
		private String idcardImg;//头像地址
		private User user;		//绑定user
	    private Post post;		//绑定岗位
		private List<RewardAndPunishiment> raps=new ArrayList<RewardAndPunishiment>();

	   // private List<Transfer> transfers=new ArrayList<Transfer>();
		//get方法
		@Id
		@GeneratedValue(strategy=GenerationType.IDENTITY)
		public Long getEmpId() {
			return empId;
		}
		public String getEmpName() {
			return empName;
		}

		public Sex getSex() {
			return sex;
		}
		@JsonFormat(pattern = "yyyy/MM/dd ",timezone="GMT+8")
		@Temporal(TemporalType.DATE)
		public Date getBirthday() {
			return birthday;
		}
		@JsonFormat(pattern = "yyyy/MM/dd ",timezone="GMT+8")
		@Temporal(TemporalType.DATE)
		public Date getJoinTime() {
			return joinTime;
		}
		public String getBornPlace() {
			return bornPlace;
		}
		public String getAddress() {
			return address;
		}
		public String getEmail() {
			return email;
		}
		public String getPhone() {
			return phone;
		}
		public String getEducation() {
			return education;
		}
		public String getPolitical() {
			return political;
		}
		public String getEthnic() {
			return ethnic;
		}
		public String getIdcard() {
			return idcard;
		}
		public String getIdcardImg() {
			return idcardImg;
		}
		@OneToOne(cascade=CascadeType.REMOVE)
		@JoinColumn
		public User getUser() {
			return user;
		}
		@ManyToOne
		@JoinColumn
		public Post getPost() {
			return post;
		}
		@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
		@JoinColumn(name="employee_id")
		public List<RewardAndPunishiment> getRaps() {
			return raps;
		}
		//set方法
		
		public void setUser(User user) {
			this.user = user;
		}

		
		public void setPost(Post post) {
			this.post = post;
		}
		public void setEmpId(Long empId) {
			this.empId = empId;
		}

		public void setEmpName(String empName) {
			this.empName = empName;
		}
		public void setSex(Sex sex) {
			this.sex = sex;
		}
		public void setBirthday(Date birthday) {
			this.birthday = birthday;
		}
		public void setJoinTime(Date joinTime) {
			this.joinTime = joinTime;
		}
		public void setBornPlace(String bornPlace) {
			this.bornPlace = bornPlace;
		}
		public void setAddress(String address) {
			this.address = address;
		}
		public void setEmail(String email) {
			this.email = email;
		}
		public void setPhone(String phone) {
			this.phone = phone;
		}
		public void setEducation(String education) {
			this.education = education;
		}
		public void setPolitical(String political) {
			this.political = political;
		}
		public void setEthnic(String ethnic) {
			this.ethnic = ethnic;
		}
		public void setIdcard(String idcard) {
			this.idcard = idcard;
		}
		public void setIdcardImg(String idcardImg) {
			this.idcardImg = idcardImg;
		}
		public void setRaps(List<RewardAndPunishiment> raps) {
			this.raps = raps;
		}
		
		
}
